#define _CRT_SECURE_NO_WARNINGS 1
#include"Dancea.h"
void InitQueue(LinkQueue* Q)
{
	Q->head = Q->rear = NULL;
	//QNode* newnode = (QNode*)malloc(sizeof(QNode));
	//newnode->next = NULL;
	//Q->head = Q->rear = newnode;
}
bool EmptyQueue(LinkQueue* Q)
{
	if (Q->head == NULL)
	{
		return true;
	}
	else
		return false;
}
void InQueue(LinkQueue* Q, Datatype x)
{

	QNode* newnode = (QNode*)malloc(sizeof(QNode));
	newnode->val = x;
	newnode->next = NULL;
	if (EmptyQueue(Q))
	{
		Q->head = Q->rear = newnode;

	}
	else
	{
		Q->rear->next = newnode;
		Q->rear = newnode;
	}
}
void DeQueue(LinkQueue* Q, Datatype* x)
{
	if (EmptyQueue(Q))
	{
		perror("Queue Empty");
		return;
	}

	QNode* del = Q->head;
	*x = del->val;
	Q->head = Q->head->next;
	if (Q->head == NULL)
	{
		Q->head = Q->rear = NULL;
	}
	free(del);
}
bool GetFront(LinkQueue* Q, Datatype* x)
{
	if (EmptyQueue(Q))
	{
		perror("Queue Empty");
		return false;
	}
	*x = Q->head->val;
	return true;
}